package com.qf.day05;

import java.util.Random;

public class Cat {
    String variety;
    String color;
    int age;
    String name;
    String sex;

    public Cat(String variety, String color, int age, String name, String sex, int happy, double weight) {
        this.variety = variety;
        this.color = color;
        this.age = age;
        this.name = name;
        this.sex = sex;
        this.happy = happy;
        this.weight = weight;
    }

    int happy;
    double weight;

    public void eat(){
        int weight =30;
        Random random = new Random();
        int time = 1+random.nextInt(20);
        System.out.println(name+"在吃饭,吃了"+time+"分钟");
        this.weight = this.weight + 1;
        happy = happy +1;
        System.out.println("体重为:"+this.weight+",心情为"+happy);
    }

    public void sleep(){
        Random random = new Random();
        int time = 1+random.nextInt(60);
        System.out.println(name+"在睡觉,睡了"+time+"分钟");
        happy = happy +1;
        System.out.println("心情为"+happy);
    }
    public void bubble() {
        //冒泡排序算法
        int[] numbers=new int[]{1,5,8,2,3,9,4};
        //需进行length-1次冒泡
        for(int i=0;i<numbers.length-1;i++)
        {
            for(int j=0;j<numbers.length-1-i;j++)
            {
                if(numbers[j]>numbers[j+1])
                {
                    int temp=numbers[j];
                    numbers[j]=numbers[j+1];
                    numbers[j+1]=temp;
                }
            }
        }
        System.out.println("从小到大排序后的结果是:");
        for(int i=0;i<numbers.length;i++)
            System.out.print(numbers[i]+" ");
    }

}

